/*
 * Copyright 2012 Faculty of Informatics - Masaryk University.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cz.muni.fi.pa165.creatures.model;

/**
 * {@code DefenseStreategy} represents dominant behavior of {@link CreatureType}
 * during combat. All {@link Creature}s of the same {@link CreatureType} has the
 * same {@code DefenseStrategy}
 *
 * @author xvojtis2
 */
public enum DefenseStrategy {

    RETREAT("retreat"),
    CLOAK("cloak"),
    ATTACK("attack"),
    SUICIDE_ATTACK("suicide"),
    NONE("none");
    private String strategy;

    private DefenseStrategy(String strategy) {
        this.strategy = strategy;
    }

    @Override
    public String toString() {
        return this.strategy;
    }

    public static DefenseStrategy fromString(String strategy) {
        if (strategy != null) {
            for (DefenseStrategy d : DefenseStrategy.values()) {
                if (strategy.equals(d.strategy)) {
                    return d;
                }
            }
        }
        return null;
    }
}
